/* 
 * @moduleName: TransFormCheckBoxUtil.js
 * @Desc: 复选框组件
 * @Author: djkloop 
 * @Date: 2017-11-30 11:59:58 
 * @Last Modified by: djkloop
 * @Last Modified time: 2017-12-12 02:19:07
 */

 import React from 'react'
 import colUtil from './ColWrapperUtil'
 import { Checkbox } from 'antd'
 const CheckboxGroup = Checkbox.Group

 export default {
  transformCheckBox(field,type) {
    let _rules = field.dateRules && type === 'single' ? field.dateRules.rules : [];
    const options = []
    field.options.forEach((option) => {
      options.push({label: option.value, value: option.key,disabled:option.disabled});
    })

    return colUtil.colWrapper((getFieldDecorator,forUpdate) => getFieldDecorator(field.key, {rules:_rules,initialValue: forUpdate ? undefined : field.defaultValue})(
      <CheckboxGroup options={options}/>
    ), field)
  }
 }
